<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        html,body{
            background-image: url(./images/login-background.jpg) ;
            background-repeat:repeat;
        }
        .box{
            width: 500px;
            height: 400px;
            background-color: white;
            margin: 200px auto;
            border-radius: 10px;
        }
        p{
            text-align: center;
            font-size: 30px;
            line-height: 100px;
        
        }
        input{
           width: 400px; 
           height: 40px;
          margin-left: 50px;
          margin-top:20px;
          border-radius: 5px;
        }
       
    </style>
</head>
<body>
    <div class="box">
        <p>后台管理系统</p>
        <input type="text" placeholder="用户名">
        <input type="password" placeholder="密码">
        <input type="password" placeholder="确认密码">
        <input type="button" value="登陆" style="color:white ;background-color: blue;" class="btn"> <br>
        <span style="margin-left: 320px;" class="tiaozhuan">使用已有账号登陆</span>
    </div>
</body>
</html>
<script src="./axios.min.js"></script>
<script>
var inputs = document.querySelectorAll('input')
console.log(inputs);
var btns = document.querySelector('.btn')
console.log(btns);

function jump(){
    location.replace('http://localhost:9090/登陆.html')
}
btns.onclick = function () {
    if ( inputs[0].value &&inputs[1].value &&inputs[2].value  ) {
        if (/^1[3-9]\d{9}$/.test(inputs[0].value)&&inputs[1].value==inputs[2].value) {
            axios.post('/api/register', {
                phone: inputs[0].value,
                pass: inputs[1].value,
            }).then((res) => {
                console.log(res.data);
            })
            alert('注册成功')
            jump()
        } else if (/^1[3-9]\d{9}$/.test(inputs[0].value) == false) {
            alert('手机号格式不正确')
        }else{
            alert('两次密码不一致')
        }
    } else {
        alert('注册信息不完整')
    }
}

</script>